<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="../assets/lib/echarts/echarts.min.js"></script>
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px; height: 400px"></div>
    <script type="text/javascript">
      // 基于准备好的dom，初始化echarts实例
      const myChart = echarts.init(document.querySelector("#main"));

      // 指定图表的配置项和数据
      const option = {
        title: {
          text: "薪资",
        },
        tooltip: {
          trigger: "axis",
        },
        //底部滑块
        dataZoom: [
          {
            show: true,
            realtime: true,
            start: 30,
            end: 70,
            xAxisIndex: [0, 1],
          },
          {
            type: "inside",
            realtime: true,
            start: 30,
            end: 70,
            xAxisIndex: [0, 1],
          },
        ],
        //图例组件

        legend: {},
        //正上方图标
        toolbox: {
          show: true,
          //右上角的工具栏
          /*    feature: {
            dataZoom: {
              yAxisIndex: "none",
            },
            dataView: { readOnly: false },
            magicType: { type: ["line", "bar"] },
            restore: {},
            saveAsImage: {},
          }, */
        },
        //x轴
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        //y轴
        yAxis: {
          type: "value",
        },
        //线条
        series: [
          {
            name: "期望薪资",
            type: "line",
            data: [10, 11, 13, 11, 12, 12, 9],
            smooth: true,
            //实心圆
            symbol: "circle",

            markLine: {
              data: [{ type: "average", name: "Avg" }],
            },
          },
          {
            name: "实际薪资",
            type: "line",
            data: [1, -2, 2, 5, 3, 2, 0],
            smooth: true,
            symbol: "circle",
            //标线
            markLine: {
              data: [
                { type: "average", name: "Avg" },
                [
                  {
                    symbol: "none",
                    x: "90%",
                    yAxis: "max",
                  },
                  {
                    symbol: "circle",
                    label: {
                      position: "start",
                      formatter: "Max",
                    },
                    type: "max",
                    name: "最高点",
                  },
                ],
              ],
            },
          },
        ],
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    </script>
  </body>
</html>
